public class Main {
    public static int func(int[] arr){
        int left = 0;
        int right = arr.length-1;
        int ret = 0;
        while(left < right){
            //计算体积
            int v = Math.min(arr[left],arr[right]) * (right-left);
            ret = Math.max(ret,v);

            //短的那一边往内缩
            if(arr[left] < arr[right]){
                left++;
            }else{
                right--;
            }
        }
        return ret;
    }
    public static void main(String[] args) {
      int[] arr = {1,8,6,2,5,4,8,3,7};
        System.out.println(func(arr));

    }
}